<!-- 子组件轮播图 ExamCarousel.vue -->
<template>
    <!--课程分类和走马灯 start-->
    <div class="carousel-container edu-container edu-banner">
     <!--骨架屏 start-->
     <el-skeleton class="horizontal-skeleton" :loading="loading" animated>
      <template #template>
        <div style="padding: 20px;width: 265px">
          <el-skeleton-item variant="h3" style="width: 50%" />
          <div style="margin-top: 15px;">
            <el-skeleton-item variant="text" style="padding: 10px 10px 10px 0;margin-right: 16px" />
            <el-skeleton-item variant="text" style="padding: 10px 10px 10px 0;width: 30%" />
            <el-skeleton-item variant="text" style="padding: 10px 10px 10px 0;margin-right: 16px" />
            <el-skeleton-item variant="text" style="padding: 10px 10px 10px 0;width: 30%" />
            <el-skeleton-item variant="text" style="padding: 10px 10px 10px 0;margin-right: 16px" />
            <el-skeleton-item variant="text" style="padding: 10px 10px 10px 0;width: 30%" />
            <el-skeleton-item variant="text" style="padding: 10px 10px 10px 0;margin-right: 16px" />
            <el-skeleton-item variant="text" style="padding: 10px 10px 10px 0;width: 30%" />
          </div>
        </div>
        <el-skeleton-item variant="image" />
      </template>
      <template #default>
        <!--左边课程分类 start-->
        <div class="edu-banner-left">
          <div class="edu-banner-item" v-for="item in categoryTree" :key="item.id">
            <span>{{item.name}}&nbsp;/&nbsp;{{item.children.length>0?item.children[0].name:''}}&nbsp;/&nbsp;{{item.children.length>0?item.children[1].name:''}} <img src="/images/edu/right.png"> </span>
            <div class="edu-banner-nav">
              <h3>{{item.name}}</h3>
              <div class="banner-list">

                <a href=""  class="banner-list-item" v-for="course in item.eduCourseList" :key="course.id">
                  <router-link :to="'/edu/details/'+course.id" :title="course.title" target="_blank">
                    <div class="banner-list-img"><img :src="course.cover"> </div>
                    <div class="banner-list-text">
                      {{ course.shortTitle}}
                    </div>
                  </router-link>
                </a>

              </div>
            </div>
          </div>
        </div>
        <!--左边课程分类 end-->

        <!--右边走马灯 start-->
        <div class="edu-banner-right">
          <div class="slider single-item">

            <!--幻灯片 start-->
            <div class="block">
                <el-carousel height="380px" indicator-position="inside" arrow="always">
                    <el-carousel-item v-for="(item, index) in carouselItems" :key="index">
                        <div class="carousel-item"
                            :style="`background: linear-gradient(rgba(0,0,0,0.3), rgba(0,0,0,0.3)), url(${item.image})`">
                            <h3>{{ item.title }}</h3>
                            <p>{{ item.description }}</p>
                            <el-button type="primary" round @click="handleCarouselClick(item)">{{ item.buttonText }}</el-button>
                        </div>
                    </el-carousel-item>
                </el-carousel>
            </div>
            <!--幻灯片 end-->
          </div>
        </div>
        <!--右边走马灯 end-->
      </template>
    </el-skeleton>
    <!--骨架屏 end-->
    </div>
    <!--课程分类和走马灯 end-->
    <!--课程类型 start-->
  <div class="row-bottom-type edu-container carousel-container">
    <div class="bottom-type">
      <div class="type-left">
        <img src="/images/edu/chuji.png" alt="初级课程" title="初级课程">
      </div>
      <div class="type-right">
        <div class="right-title">初级课程</div>
        <div class="right-desc">入门课、岗位多</div>
      </div>
    </div>
    <div class="bottom-type">
      <div class="type-left">
        <img src="/images/edu/zhongji.png" alt="中级课程" title="中级课程">
      </div>
      <div class="type-right">
        <div class="right-title">中级课程</div>
        <div class="right-desc">进阶与实战</div>
      </div>
    </div>
    <div class="bottom-type">
      <div class="type-left">
        <img src="/images/edu/gaoji.png" alt="高级课程" title="高级课程">
      </div>
      <div class="type-right">
        <div class="right-title">高级课程</div>
        <div class="right-desc">轻松掌握核心技能</div>
      </div>
    </div>
    <div class="bottom-type">
      <div class="type-left">
        <img src="/images/edu/xiangmu.png" alt="项目实战" title="项目实战">
      </div>
      <div class="type-right">
        <div class="right-title">项目实战</div>
        <div class="right-desc">手把手实践</div>
      </div>
    </div>
    <div class="bottom-type">
      <div class="type-left">
        <img src="/images/edu/suanfa.png" alt="面试课程" title="面试课程">
      </div>
      <div class="type-right">
        <div class="right-title">面试课程</div>
        <div class="right-desc">吊打面试官</div>
      </div>
    </div>
  </div>
  <!--课程类型 end-->
</template>
<script setup lang="ts">
import { useRouter } from 'vue-router'
const router = useRouter()
  const props = defineProps({
    carouselItems: {
      type: Array,
      required: true
    },
    categoryTree: {
        type: Array,
        required: true
    },
    loading: {
      type: Boolean,
      default: true
    }
  })

  const handleCarouselClick = (item:any) => {
    console.log('item:',item)
  if (item.linkType === 1) {
    router.push(item.linkUrl)
  } else {
    window.open(item.linkUrl, '_blank')
  }
}

</script>
<style lang="scss" scoped>
// 轮播图 start
.skeleton-carousel {
    position: relative;
}

.skeleton-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    width: 80%;
}

.carousel-container {
    max-width: 1400px;
    margin: 20px auto;


    .el-carousel {
        border-radius: 0 12px 12px 0;
        overflow: hidden;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }

    .carousel-item {
        height: 400px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        color: white;
        text-align: center;
        padding: 0 20px;
        background-size: cover !important;
        background-position: center !important;

        h3 {
            font-size: 36px;
            margin-bottom: 20px;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
        }

        p {
            font-size: 18px;
            margin-bottom: 30px;
            max-width: 800px;
            line-height: 1.6;
        }

        .el-button {
            padding: 12px 40px;
            font-size: 16px;
            font-weight: bold;
            letter-spacing: 1px;
        }
    }
}

// 轮播图 end

/*栏目和走马灯样式 start*/
.edu-banner {
  height: 380px;
  display: flex;
  justify-content: flex-start;
  margin: 15px auto;
  box-shadow: 2px 2px 10px rgb(0 0 0 / 40%);
  border-radius: 20px 20px 0 0;
}
.edu-banner-left {
  width: 263px;
  background: #2b333b;
  height: 100%;
  border-radius: 20px 0 0 0;
  position: relative;
  padding-left: 20px;
  padding-right: 10px;
  box-sizing: border-box;
}
.edu-banner-item{
  width: 100%;
  padding: 10px 10px 10px 0;
  margin-top: 20px;
}
.edu-banner-item span {
  color: #ede4e4;
  font-size: 14px;
  display: block;
  text-align: left;
  cursor: pointer;
}
.edu-banner-item span img {
  cursor: pointer;
  float: right;
  margin-top: 5px;
}
.edu-banner-nav {
  width: 1088px;
  height: 380px;
  background: #fff;
  position: absolute;
  right: -1088px;
  top: 0;
  z-index: 9;
  display: none;
}
.edu-banner-nav:after {
  content: "";
  width: 5px;
  height: 20px;
  background: #083a6d;
  border-radius: 10px;
  position: absolute;
  left: 20px;
  top: 27px;
  z-index: 3;
}
.edu-banner-nav h3 {
  color: #343434;
  font-size: 23px;
  position: relative;
  padding-left: 40px;
  border-bottom: 1px solid #e2e2e2;
}

.banner-list {
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.banner-list-item {
  display: block;
  width: 115px;
  height: 120px;
  margin: 10px 20px;
}
.banner-list-img {
  width: 115px;
  height: 72px;
  border-radius: 6px;
}

.banner-list-img img {
  width: 100%;
  height: 100%;
  border-radius: 6px;
}

.banner-list-text{
  font-size: 12px;
  color: #545c63;
  margin-top: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.edu-banner-item:hover{
  background: #999999;
  border-radius: 6px 0 0 6px;
}

.edu-banner-item:hover .edu-banner-nav{
  display: block;
}

.edu-banner-right {
  width: 1137px;
  height: 100%;
}
/*栏目和走马灯样式 end*/
/*课程类型样式 start*/
.row-bottom-type {
  margin: -15px auto 10px auto;
  display: flex;
  height: 100px;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 55px 25px -25px #d7dae1;
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
  border-left: 1px solid #eee;
  border-bottom: 1px solid #eee;
  border-right: 1px solid #eee;
  background: #ffffff;
}
.bottom-type {
  width: 20%;
  display: flex;
  justify-content: center;
  align-items: center;
}
.bottom-type .type-left {
  width: 50px;
  height: 50px;
}
.bottom-type .type-left img {
  width: 100%;
  height: 100%;
}

.type-right {
  margin-left: 10px;
}

.right-title {
  font-size: 18px;
  font-weight: bold;
}
.right-desc {
  font-size: 14px;
  color: #999;
}
/*课程类型样式 end*/
</style>